home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
102
/
examples
/
textswis.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-01-25
|
5KB
|
110 lines
/* Programmer's guide to GEM - 1986 - p.158 -listing 3.2 - CJPurcell Dec'86 */
/* CTRLRC.C - MAIN DRIVER for draw_rc() examples using Mark Williams C */
/* to be tested in NDC and/or RC mode with or without GDOS for implications */
#include <portab.h> /* try <> and see ?? */
#include <osbind.h> /* system constants */
#include <gemdefs.h> /* GEM-definition */
/* #include <obdefs.h> / * object definition*/
WORD contrl[12], intin[128], ptsin[128], intout[128], ptsout[128];
#define M_OFF 256
#define RC_COORDS 2
#define RIGHT_ALIGNED 2
#define BOTTOM_ALIGNED 3
VOID main() /* not GEMAIN as in ref. */
{
WORD handle, work_in[11], work_out[57], max_w, max_h;
WORD ii;
appl_init(); /* init AES for call */
handle = graf_handle( &ii,&ii,&ii,&ii ); /* get screen handle */
graf_mouse( M_OFF, NULL ); /* hide mouse */
v_clrwk( handle ); /* clear workstation */
for( ii=0; ii<11; ++ii ) work_in[ii]=1; /* init work_in array*/
work_in[10] = RC_COORDS; /* using RC coordinates */
v_opnvwk( work_in, &handle, work_out ); /* open the workstation */
max_w = work_out[0]; max_h = work_out[1];
draw_rc( handle,0,0,max_w,max_h ); /* do the examp.routine */
vst_alignment( handle,RIGHT_ALIGNED,BOTTOM_ALIGNED,&ii,&ii );
v_gtext( handle,max_w,max_h,"Press any Key to Continue" );
evnt_keybd(); /* pause for viewing */
v_clsvwk( handle ); /* close workstation */
appl_exit(); /* tell AES finished */
}
/* Programmer's Guide to GEM - 1986 - p.199,Listing 3.13 - CJPurcell- Dec'86 */
/* TEXTSWIS.C - display text alignment for SWISS font lower case letters GDOS*/
/* #include <portab.h> */
#define SYSTEM_FONT 0
#define SWISS_FONT 2
#define LEFT_ALIGN 0
#define BASELINE 0
#define SMALL_LETTERS 10
#define BIG_LETTERS 72
#define COLOR_LETTERS 36
BYTE *y_labels[6] = { " 0:baseline "," 1:half ", " 2:ascent ",
" 3:bottom " , " 4:descent ", " 5:top " };
/* FUNCTION print_line */
WORD print_line( handle, text, cur_x, cur_y, point_size, font_type )
WORD handle, cur_x, cur_y, point_size, font_type ;
BYTE *text;
{
WORD pxy[4], junk, ver_in;
WORD y_lines[6]; /* table of row positions */
WORD distances[5], effects[3]; /* for vqt_font_info() */
WORD extents[8]; /* for vqt_extent() */
vst_font( handle, font_type ); /* use requested font-type */
vst_alignment( handle, LEFT_ALIGN, BASELINE, &junk, &junk );
vst_point( handle, point_size, &junk, &junk, &junk, &junk );
v_gtext( handle, cur_x, cur_y, text ); /* display the text */
vqt_font_info( handle,&junk, &junk, distances, &junk, effects );
y_lines[0] = cur_y; /* baseline */
y_lines[1] = cur_y - distances[2]; /* halfline */
y_lines[2] = cur_y - distances[3]; /* ascent line */
y_lines[3] = cur_y + distances[0]; /* bottom line */
y_lines[4] = cur_y + distances[1]; /* descent line */
y_lines[5] = cur_y - distances[4]; /* top line */
vqt_extent( handle, text, extents );
pxy[0] = cur_x;
pxy[2] = cur_x + extents[2]; /* right edge of text string */
vst_font( handle, SYSTEM_FONT );
vst_point( handle, SMALL_LETTERS, &junk, &junk, &junk, &junk );
for(ver_in + 5 ; ver_in >= 0; --ver_in)
{
pxy[1] = pxy[3] = y_lines[ver_in];
v_pline( handle, 2, pxy);
v_gtext( handle, pxy[2], pxy[3], y_labels[ver_in] );
}
return distances[0]+distances[4]; /*distance bottom to top line*/
}
/* FUNCTION draw_rc */
VOID draw_rc( handle, dx, dy, swidth, sheight )
WORD handle, dx, dy, swidth, sheight;
{
WORD cur_x, cur_y, resize ;
resize = COLOR_LETTERS ; /* presume color system, but*/
if ( 2 == Getrez() ) resize = BIG_LETTERS ;
vst_load_fonts( handle, 0 ); /* load all available fonts */
cur_x = dx + (swidth / 32 );
cur_y = dy + (sheight / 4 ) ;
cur_y += print_line( handle, "abcdefghijkl", cur_x, cur_y,
resize , SWISS_FONT );
cur_y += print_line( handle, "MNOPQRST", cur_x, cur_y,
resize , SWISS_FONT );
print_line( handle, "uvwxyz", cur_x, cur_y, resize, SWISS_FONT );
vst_unload_fonts( handle, 0 );
} /* CJPurcell 08Dec'86 */